﻿@model IEnumerable<yule.Model.Sys.Region>
@{
    yule.Util.RunTime rt = new yule.Util.RunTime();
    ViewBag.Title = "Index";
}
<table id="table_data">
    <tr>
        <th>Id</th>
        <th>Code</th>
        <th>Name</th>
        <th>ParentId</th>
        <th>PathId</th>
        <th>PathName</th>
        <th>操作</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@item.Id</td>
            <td>@item.Code</td>
            <td>@item.Name</td>
            <td>@item.PathId</td>
            <td>@item.ParentId</td>
            <td>@item.PathName</td>
            <td>
                <a onclick="Edit('@item.Id','@item.Name');" href="#">Ajax编辑</a> |
                @Html.ActionLink("编辑", "Edit", new { id = item.Id }) |
                <a onclick="Detail('@item.Id','@item.Name');" href="#">Ajax详细</a> |
                @Html.ActionLink("详细", "Details", new { id = item.Id }) |
                @Html.ActionLink("删除", "Delete", new { id = item.Id })
            </td>
        </tr>
    }
</table>


<script type="text/javascript">
    $("#table_data tr").each(function (index) {
        if (index > 0) {
            $(this).hover(function () {
                $(this).addClass("tr_mouseover");
            },
            function () {
                $(this).removeClass("tr_mouseover");
            });
        }
    })

    function Detail(id,name) { 
        
        $.blockUI();

        $.ajax({
            url:"@Url.Action("Details")?id="+id,
            success:function(html){
                alert(html,name);
            },
            complete:function(){
                $.unblockUI();
            }
        });
    };

    function Edit(id,name){
        
        $.blockUI();

        $.ajax({
            url:"@Url.Action("Edit")?id="+id,
            success:function(html){
                alert(html,name,{ok:false});
            },
            complete:function(){
                $.unblockUI();
            }
        });
    };

    function confirmDelete(msg) {
        return window.confirm("确定要删除信息:<" + msg + ">吗？");
    }

    var CurrentMenu = "地区";
</script>

<div class="PageLoadInfo">@(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 页面加载消耗 " + rt.GetTotal() + " 毫秒")</div>